/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
export default function access(initialState) {
  const { currentUser } = initialState ?? {};
  console.log("----", JSON.stringify(currentUser?.permissionCodes));
  const permissionCodes = currentUser?.permissionCodes || [];

  const permissionList = [
    "INDEX_PAGE",
    "AUCTION_MANAGE_PAGE",
    "USER_PAGE",
    "ORDER_PAGE",
    "CONTRACT_PAGE",
    "INFORMATION_PAGE",
    "PERMISSION_PAGE",
    "SYSTEM_SETTING_PAGE",
    "AUCTION_LIST_PAGE",
    "CATEGORY_LIST_PAGE",
    "ORDER_LIST_PAGE",
    "TAKE_ORDER_PAGE",
    "ROLE_PAGE",
    "ADMIN_LIST_PAGE",
    "ROTATION_PAGE",
    "LOGISTICS_PAGE",
  ];
  if (currentUser?.account === "admin") {
    permissionCodes.push("ADMIN");
  }
  let obj = {};
  permissionList.forEach((item) => {
    obj[item] = permissionCodes.includes(item);
  });
  console.log("obj===", obj);
  return obj;
}
